package API_Jung;


    import edu.uci.ics.jung.visualization.VisualizationViewer;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.table.DefaultTableModel;
import metodologia.ToDoNode;

public class MyMouseMenusToDo implements java.io.Serializable{
    
   public static class EdgeMenu2 extends JPopupMenu {        
        // private JFrame frame; 
        public EdgeMenu2() {
            super("Edge Menu");
            // this.frame = frame;
            this.add(new DeleteEdgeMenuItem<String>());
        }
        
    }

    /*
    public static class WeightDisplay extends JMenuItem implements EdgeMenuListener<GraphElements.MyEdge> {
        public void setEdgeAndView(GraphElements.MyEdge e, VisualizationViewer visComp) {
            this.setText("Weight " + e + " = " + e.getWeight());
        }
    }
    
    public static class CapacityDisplay extends JMenuItem implements EdgeMenuListener<GraphElements.MyEdge> {
        public void setEdgeAndView(GraphElements.MyEdge e, VisualizationViewer visComp) {
            this.setText("Capacity " + e + " = " + e.getCapacity());
        }
    }*/
    
    public static class VertexMenu2 extends JPopupMenu {
        public VertexMenu2() {
            super("Vertex Menu");
            this.add(new VertexPropItem());
            this.addSeparator();
            this.add(new DeleteVertexMenuItem<ToDoNode>());
            
            
        }
    }
    
     public static class VertexPropItem extends JMenuItem implements VertexMenuListener<ToDoNode>,
            MenuPointListener {
        ToDoNode vertex;
        VisualizationViewer visComp;
        Point2D point;

        
        @Override
        public void setVertexAndView(ToDoNode vertex, VisualizationViewer visComp) {
            this.vertex = vertex;
            this.visComp = visComp;
        }

        @Override
        public void setPoint(Point2D point) {
            this.point = point;
        }
        
        public  VertexPropItem() {            
            super("Lista de Etapas");
            this.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                    // Determine the new location of the window
                    int w = vertex.getTodo().getSize().width;
                    int h = vertex.getTodo().getSize().height;
                    int x = (dim.width-w)/2;
                    int y = (dim.height-h)/2;

                    // Move the window
                    vertex.getTodo().setLocation(x, y);
                    vertex.getTodo().setVisible(true); 
                }
                
            });
        }
        
    }
    
}
